package com.woniu.publisher;

import com.woniu.utils.ConstantUtil;
import com.woniu.utils.RabbitMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class AddRegistrationPublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private RabbitMessageUtil rabbitMessageUtil;
    public void send(Object msg,String routingKey){
        rabbitTemplate.setConfirmCallback(rabbitMessageUtil);
        rabbitTemplate.setReturnsCallback(rabbitMessageUtil);
        log.info("挂号订单发送消息：{}",msg);
        rabbitTemplate.convertAndSend(ConstantUtil.EXCHANGE_KILL_ORDER,routingKey,msg);
    }

}
